console.log("//2遍历/*方式1 标准for循环*/");
var s = {name:'lilei', age:19, 'gender':'boy'};
for (var i=0;i<=Object.keys(s).length-1;i++){
	console.log(Object.keys(s)[i]+":"+Object.values(s)[i]);
	//console.log(Object.entries(s)[i])
	/*Object.keys() 方法会返回一个由一个给定对象的自身可枚举属性组成的数组*/
}


console.log("===============")
console.log("//2/*方式2 while循环*/");
var s = {name:'lilei', age:19, 'gender':'boy'};
var i=0;
while (i<=Object.keys(s).length-1)
{
	console.log(Object.keys(s)[i]+":"+Object.values(s)[i])
	i+=1;
}


console.log("==================")
console.log("//2/*方式3 do while循环*/");
var s = {name:'lilei', age:19, 'gender':'boy'};
var i=0;
do
{
	console.log(Object.keys(s)[i]+":"+Object.values(s)[i]);
	i+=1;
}
while(i<=Object.keys(s).length-1)

console.log("=====================")
console.log("//2/*方式4 for in 遍历对象/字典属性 */");
var s = {name:'lilei', age:19, 'gender':'boy'};
var i=0;
for (var i in s)
{
	console.log(i+":"+s[i]);
}

console.log("=====================")
console.log("//2/*方式5 for of 遍历数组*/");
var s = {name:'lilei', age:19, 'gender':'boy'};

for (const [key, value] of Object.entries(s))
{
	console.log(`${key}: ${value}`);
}

console.log("=====================")
console.log("//2/*方式6 forEach函数*/");
var s = {name:'lilei', age:19, 'gender':'boy'};
function foreach(obj,fn)
{
	for (key in obj)
		{fn(key,obj[key]);}
		
}
foreach (s,function(key,val){
	console.log(key+":"+val);
})

console.log("=====================")
console.log("//2/*方式7 map函数*/");
function map(obj,fn)
{
	for (key in obj)
		{fn(key,obj[key]);}
		
}
map(s,function(key,val){
	console.log(key+":"+val);
})
 